package ytr.android.sparrow;

import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

/**
 * <pre>
 * 麻雀スコア管理画面クラス フッター部データ格納処理。
 * @author toki
 * </pre>
 */
public class ScoreManagementAdapteFooter extends ArrayAdapter<ScoreManagementItemFooter> {


	/**
	 * 呼び出し元のレイアウトを操作するためのオブジェクト
	 */
	private LayoutInflater mLayoutInflater;

	/**
	 * レイアウトを動的に操作するための情報
	 */
	private List<Integer> m_iColSizeList;

	/**
	 * リストビューコントロールクラス
	 */
	private static class ViewHolder {
		TextView footer_brank;
		TextView footer_1;
		TextView footer_2;
		TextView footer_3;
		TextView footer_4;
		TextView footer_5;
		TextView footer_6;
	}

	/**
	 * コンストラクタ
	 * @param context
	 * @param textViewResourceId
	 * @param objects
	 */
	public ScoreManagementAdapteFooter(Context context, int textViewResourceId, List<ScoreManagementItemFooter> objects, List<Integer> colSizeList) {
		super(context, textViewResourceId, objects);

		mLayoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		m_iColSizeList = colSizeList;
	}
	
	/**
	 * リスト描画処理
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ScoreManagementItemFooter item = (ScoreManagementItemFooter)getItem(position);
		ViewHolder viewHolder;

		if (null == convertView) {
			convertView = mLayoutInflater.inflate(R.layout.score_management_row, null);
			viewHolder = new ViewHolder();

			viewHolder.footer_brank = (TextView) convertView.findViewById(R.id.listFooter_Label);
			viewHolder.footer_1 = (TextView) convertView.findViewById(R.id.listFooter_Text1);
			viewHolder.footer_2 = (TextView) convertView.findViewById(R.id.listFooter_Text2);
			viewHolder.footer_3 = (TextView) convertView.findViewById(R.id.listFooter_Text3);
			viewHolder.footer_4 = (TextView) convertView.findViewById(R.id.listFooter_Text4);
			viewHolder.footer_5 = (TextView) convertView.findViewById(R.id.listFooter_Text5);
			viewHolder.footer_6 = (TextView) convertView.findViewById(R.id.listFooter_Text6);

			viewHolder.footer_brank.setWidth(m_iColSizeList.get(0));
			viewHolder.footer_1.setWidth(m_iColSizeList.get(1));
			viewHolder.footer_2.setWidth(m_iColSizeList.get(2));
			viewHolder.footer_3.setWidth(m_iColSizeList.get(3));
			viewHolder.footer_4.setWidth(m_iColSizeList.get(4));
			viewHolder.footer_5.setWidth(m_iColSizeList.get(5));
			viewHolder.footer_6.setWidth(m_iColSizeList.get(6));

			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder)convertView.getTag();
		}

		return convertView;
	}
}


